<?php
require_once('libs/MySmarty.php');
require_once('libs/DbAccess.php');
require_once('classes/category.class.php');



$_action = isset($_REQUEST['actionType']) ? $_REQUEST['actionType'] : 'view';
$lang_id = isset($_GET['lang_id']) ? $_GET['lang_id'] : 1;
$cmd_name= htmlspecialchars(@$_POST['cmd']);
$formPage = new category($lang_id);
switch($_action) {
    case 'catEdit':
        if($_POST['category_name'] == ""){
			$formPage->msg = "カテゴリ名を入力してください！";
			$formPage->smarty->assign('msg', $formPage->msg);
		}else{
			$formPage->insertCat($_POST);
		}
        break;
    case 'keywordEdit':
		if($cmd_name == "親カテゴリ削除")
		{
			$formPage->delCat($_POST);
		}
		else if($cmd_name == "タグ追加")
		{
			if($_POST['keyword_name'] == ""){
				$formPage->msg = "タグ名を入力してください！";
				$formPage->smarty->assign('msg', $formPage->msg);
			}else{		
				$formPage->insertKeyWord($_POST);
			}
		}
        break;
	case 'keywordDel':
		if($_POST['tag_id'] == ""){
			$formPage->msg = "タグIDを入力してください！";
			$formPage->smarty->assign('msg', $formPage->msg);
		}else{		
			$formPage->delKeyWord($_POST);
		}
		
        break;
    case 'view':
    default:
        // viewing the guestbook
        break;   
}

$formPage->initDropDown();
$formPage->showTree();   

?>